package net.spacebeeshooter.gui;

import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;

import net.spacebeeshooter.main.ErrorGenerator;

public class MenuButton extends JButton {
	
	private static final long serialVersionUID = -5493970275594664715L;

	public MenuButton(String iconPath, String textIfIconIsNotFound) {
		setOpaque(false);
		try {
			setIcon(new ImageIcon(ImageIO.read(new File(iconPath)).getScaledInstance(12, 12, Image.SCALE_SMOOTH)));
		} catch(IOException e) {
			new ErrorGenerator().generateErrorMessage("Loading of icon '" + iconPath + "' failed.");
			setText(textIfIconIsNotFound);
		}
	}

}
